import java.util.Scanner;

public class twu {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int l = scanner.nextInt();
        int m = scanner.nextInt();
        boolean[] removed = new boolean[l + 1];
        for (int i = 0; i < m; i++) {
            int u = scanner.nextInt();
            int v = scanner.nextInt();
            for (int j = u; j <= v; j++) {
                removed[j] = true;
            }
        }
        int count = 0;
        for (int i = 0; i <= l; i++) {
            if (!removed[i]) {
                count++;
            }
        }
        System.out.println(count);
    }
}

